package com.oms.app.user.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import com.oms.app.user.dao.IGroupDAO;
import com.oms.app.user.model.Group;
import com.oms.core.dao.impl.GeneralDAO;

/**
 * controller
 * @author wtj
 * @date Sep 10, 2012  10:14:21 PM
 */

public class GroupDAOImpl extends GeneralDAO<Object, String> implements IGroupDAO {

	@Override
	public List getGroupList(HttpServletRequest request) {
		return this.queryForList("getAll",new HashMap<String, String>());
	}

	@Override
	public int delete(String primaryKey) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object get(String primaryKey) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean groupAddRole(Map map) {
		this.insert("insertGroupRole", map);
		return false;
	}

	@Override
	public boolean groupAddUser(Map map) {
		return false;
	}

	@Override
	public boolean saveOrUpdateGroup(Group groupForm) {
		System.out.println(JSONObject.fromObject(groupForm).toString());
		this.insert(groupForm);
		return false;
	}

	@Override
	public boolean deleteGroup(String PK) {
		try {
			this.delete("delete", PK);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public boolean isGroupRole(Map map) {
		int ct = this.getCount("isGroupRole", map);
		System.out.println("2012年9月18日21:12:33："+ct);
		return (ct > 0);
	}
	
}
